var person = {
    name : "小明",
    age : 18,
    say : function(){
        alert(this.name);
    }
}
//将person对象的name属性的writable特性置为false[属性只读效果]
Object.defineProperty(person, "name", {
    writable : false
});
person.name = "张三";//name属性修改操作无效
person.say();

//属性的Getter和Setter
var book = {
    _name : "JS教程",
    show : function(){
        alert(this.name);
    }
}

Object.defineProperty(book,"name",{
    get : function(){
        return this._name;
    },
    set : function(name){
        this._name = name+" SET";
    }
});
book.name = "我是书名";
book.show();